/**
 * @Date 2023-02-11 11:17:14
 * @Remark block1
 */

import UrlParse from "url-parse";

// 获得UrlParse对象
function getParseUrl(url: string) {
  return new UrlParse(url);
}

// 获得携带参数
function getUrlQuery(location: any) {
  const url = getParseUrl(`${location.pathname}${location.search}`);
  return url.query;
}

// 获得id
function getUrlId(props: any): number {
  const { match } = props;
  const { id } = match.params;
  const params = parseInt(id, 10);
  return params;
}

const urlUtils = {
  getParseUrl,
  getUrlQuery,
  getUrlId,
};
export default urlUtils;
